﻿using System;
using System.IO;
using UnityEngine;

namespace Studio
{
	// Token: 0x020004AD RID: 1197
	internal static class Utility
	{
		// Token: 0x06001DFB RID: 7675 RVA: 0x000BE4C4 File Offset: 0x000BC6C4
		public static bool SetColor(ref Color currentValue, Color newValue)
		{
			if (currentValue.r == newValue.r && currentValue.g == newValue.g && currentValue.b == newValue.b && currentValue.a == newValue.a)
			{
				return false;
			}
			currentValue = newValue;
			return true;
		}

		// Token: 0x06001DFC RID: 7676 RVA: 0x000BE524 File Offset: 0x000BC724
		public static bool SetStruct<T>(ref T currentValue, T newValue) where T : struct
		{
			if (currentValue.Equals(newValue))
			{
				return false;
			}
			currentValue = newValue;
			return true;
		}

		// Token: 0x06001DFD RID: 7677 RVA: 0x000BE548 File Offset: 0x000BC748
		public static bool SetClass<T>(ref T currentValue, T newValue) where T : class
		{
			if ((currentValue == null && newValue == null) || (currentValue != null && currentValue.Equals(newValue)))
			{
				return false;
			}
			currentValue = newValue;
			return true;
		}

		// Token: 0x06001DFE RID: 7678 RVA: 0x000BE5A4 File Offset: 0x000BC7A4
		public static void SaveColor(BinaryWriter _writer, Color _color)
		{
			_writer.Write(_color.r);
			_writer.Write(_color.g);
			_writer.Write(_color.b);
			_writer.Write(_color.a);
		}

		// Token: 0x06001DFF RID: 7679 RVA: 0x000BE5DC File Offset: 0x000BC7DC
		public static Color LoadColor(BinaryReader _reader)
		{
			Color result;
			result.r = _reader.ReadSingle();
			result.g = _reader.ReadSingle();
			result.b = _reader.ReadSingle();
			result.a = _reader.ReadSingle();
			return result;
		}

		// Token: 0x06001E00 RID: 7680 RVA: 0x000BE620 File Offset: 0x000BC820
		public static T LoadAsset<T>(string _bundle, string _file, string _manifest) where T : UnityEngine.Object
		{
			return CommonLib.LoadAsset<T>(_bundle, _file, true, _manifest);
		}

		// Token: 0x06001E01 RID: 7681 RVA: 0x000BE62C File Offset: 0x000BC82C
		public static float StringToFloat(string _text)
		{
			float num = 0f;
			return (!float.TryParse(_text, out num)) ? 0f : num;
		}

		// Token: 0x06001E02 RID: 7682 RVA: 0x000BE658 File Offset: 0x000BC858
		public static string GetCurrentTime()
		{
			DateTime now = DateTime.Now;
			return string.Format("{0}_{1:00}{2:00}_{3:00}{4:00}_{5:00}_{6:000}", new object[]
			{
				now.Year,
				now.Month,
				now.Day,
				now.Hour,
				now.Minute,
				now.Second,
				now.Millisecond
			});
		}

		// Token: 0x06001E03 RID: 7683 RVA: 0x000BE6E4 File Offset: 0x000BC8E4
		public static Color ConvertColor(int _r, int _g, int _b)
		{
			Color color;
			return (!ColorUtility.TryParseHtmlString(string.Format("#{0:X2}{1:X2}{2:X2}", _r, _g, _b), out color)) ? Color.clear : color;
		}
	}
}
